<%= render :partial => "photo_with_profile" %>

<div id="photo-critiques" class="subsection">

  <h2>Critiques</h2>

  <% cr_count = Critique.count(["photo_id = ?", @photo]) %>

  <% if @photo.user_id != session[:user] %>
    This photo currently has <%= cr_count %> critiques.<br>
    <% if Critique.find_by_user_id_and_photo_id(session[:user], @photo) %>
    You've already critiqued this photo, and your critique is no longer editable.
    <% else %> 
      <% if cr_count < 3 %>
        If you write one of the first three conforming critiques for this photo, then you will receive three critique points every time another user rates your critique helpful.
      <% else %>
        Since there are already at least three conforming critiques, if you write a conforming critique for this photo, then you will receive only the usual one critique point every time another user rates your critique helpful.
      <% end %>

      <p><%= render :partial=>"write_critique", :object=>@photo %>

    <% end %>
  <% else %>
    Your photo currently has <%= cr_count %> critiques.<br>
  <% end %>

  <% if cr_count > 0 %>
    <p>If you find one of following critiques especially <b>helpful</b>, or especially <b>unhelpful</b>, then please take a moment to register your opinion by clicking one of the buttons to the right of the critique.
    <div id="critiques_list">
      <table width="100%" cellspacing="0" cellpadding="0" border="0">
        <%= render :partial => "critiques/critique", :collection => @photo.critiques %>
      </table>
    </div>
  <% end %>
</div>
